/* 
 * File:   devNode.h
 * Author: zhouzhao
 *
 * Created on December 25, 2011, 1:25 PM
 */

#ifndef DEVNODE_H
#define	DEVNODE_H

#include "type.h"

class devNode {
public:
__device__ __host__ devNode(int modIndex, int index, NType type, GType gate, int faninNum){

	this->modIndex = modIndex;
    this->index = index;
    this->type = type;
    this->gate = gate;
    this->logic = X;
    
    this->faninNum = faninNum;
    for(int i = 0; i < 4; i++){
        fanin[i] = -1;
        level[i] = -1;
    }
}

__device__ __host__ devNode(int modIndex, int index, NType type, GType gate, int faninNum, LType dLogic){

	this->modIndex = modIndex;
    this->index = index;
    this->type = type;
    this->gate = gate;
    this->logic = dLogic;
    
    this->faninNum = faninNum;
    for(int i = 0; i < 4; i++){
        fanin[i] = -1;
        level[i] = -1;
    }
}

__device__ __host__ devNode(){

	this->modIndex = -1;
    this->index = -1;
    this->type = DUMMY;
    this->gate = NA;
    this->logic = X;
    
    this->faninNum = -1;
    for(int i = 0; i < 4; i++){
        fanin[i] = -1;
        level[i] = -1;
    }
}

__device__ __host__ ~devNode(){
    
}

__device__ __host__ int getModule(){
	return this->modIndex;
}

__device__ __host__ int getIndex(){
    return this->index;
}

__device__ __host__ NType getType(){
    return this->type;
}

__device__ __host__ GType getGate(){
    return this->gate;
}

__device__ __host__ LType getLogic(){
    return this->logic;
}
__device__ __host__ void setLogic(LType logic){
    this->logic = logic;
}

__device__ __host__ int getFaninNum(){
    return this->faninNum;
}

__device__ __host__ int getFanin(int index){
    return fanin[index];
}
__device__ __host__ void setFanin(int index, int num){
    fanin[index] = num;
}

__device__ __host__ int getLevel(int index){
    return level[index];
}
__device__ __host__ void setLevel(int index, int num){
    level[index] = num;
}

private:
    
	int modIndex; //index of module which contains the node
    int index; //node index in one module
    
    NType type;
    GType gate;
    LType logic; //variable
    
    int faninNum;
    int fanin[4]; //fanin offset which is variable
    int level[4]; //fanin level which is variable
};

#endif	/* DEVNODE_H */
 
